<html>
<head>
<title>FindBugs FAQ</title>
<link rel="stylesheet" type="text/css" href="findbugs.css">
@GOOGLE_ANALYTICS@
</head>

<body>

<table width="100%"><tr>

@HTML_SIDEBAR@

<td>
<h1>FindBugs FAQ</h1>

<p> This document contains answers to frequently asked questions about
<a href="index.html">FindBugs</a>.&nbsp; If you just want general
information about FindBugs, have a look at the
<a href="factSheet.html">fact sheet</a> and the
<a href="manual/index.html">manual</a>.

<h2>Contents</h2>
<ol>
<li> <a href="#q1">I'm getting java.lang.UnsupportedClassVersionError when I try to run FindBugs</a>
<li> <a href="#q2">When I click the "Find Bugs!" button, I get a NoSuchMethodError or VerifyError</a>
<li> <a href="#q3">FindBugs is running out of memory, or is taking a long time to finish</a>
<li> <a href="#q4">What is the "auxiliary classpath"?  Why should I specify it?</a>
<li> <a href="#q5">The Eclipse plugin doesn't load</a>
<li> <a href="#q6">I'm getting a lot of false "OS" and "ODR" warnings</a>
<li> <a href="#q7">The Eclipse plugin loads, but doesn't work correctly</a>
<li> <a href="#q8">Where is the Maven plugin for FindBugs?</a>
<li> <a href="#q9">Where is the NetBeans plugin for FindBugs?</a>
</ol>

<h2><a name="q1">Q1: I'm getting java.lang.UnsupportedClassVersionError when I try to run FindBugs</a></h2>

<p> FindBugs requires JRE 1.7.0 or later to run.&nbsp; If you use an earlier version,
you will see an exception error message similar to the following:
<pre>
Exception in thread "main" java.lang.UnsupportedClassVersionError:
edu/umd/cs/findbugs/gui/FindBugsFrame (Unsupported major.minor version 51.0)
</pre>
The solution is to upgrade to JRE 1.7.0 or later.

<h2><a name="q2">Q2: When I click the "Find Bugs!" button, I get a NoSuchMethodError or VerifyError</a></h2>

<p> The symptom of this bug is that when you start the FindBugs analysis,
you see an exception similar to the following:
<pre>
java.lang.NoSuchMethodError: org.apache.bcel.Repository.setRepository(Lorg/apache/bcel/util/Repository;)V
        at edu.umd.cs.findbugs.FindBugs.clearRepository(FindBugs.java:483)
        ...
</pre>

or

<pre>
java.lang.VerifyError: Cannot inherit from final class
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
    ...
</pre>

<p> The problem here is that the wrong version of the
<a href="http://jakarta.apache.org/bcel/">Apache BCEL</a>
library is being found.&nbsp; FindBugs requires its own
version of BCEL, which normally will be used automatically
when you invoke the <code>findbugs</code> or <code>findbugs.bat</code>
scripts used to launch FindBugs.&nbsp; If an old version of BCEL is installed
in a location, such as "lib/endorsed" in the JRE installation,
where it overrides classes on the application classpath,
FindBugs will not execute properly.&nbsp;
We know of several reasons this could happen

<ul>
<li> If you install the
<a href="http://java.sun.com/webservices/downloads/webservicespack.html">Java(TM) Web Services
Developer Pack 1.2</a>
in the <code>lib/endorsed</code> directory of your Java Runtime Environment (JRE).&nbsp;
The file <code>xsltc.jar</code> contains an old version of BCEL that is incompatible with
FindBugs.&nbsp;

<li> Another possibility is that you are using the IBM JDK.&nbsp;
Some versions include a version of BCEL which conflicts with the
one required by FindBugs.&nbsp; This problem is fixed in version 1.4.1 SP1,
so upgrading your JDK should allow FindBugs to run correctly.

<li> Some versions of the Apache Xalan XSLT processor include
an old version of BCEL in <code>xalan.jar</code>.

</ul>

<p> In all of these cases, you should be able to run FindBugs
by either removing the offending version of BCEL from your JRE,
or installing a clean JRE or JDK and using that to run FindBugs.

<p> Many thanks to Peter Meulmeester, Michael Levi, and Thomas Klaeger
for providing information on this problem.

<h2><a name="q3">Q3: FindBugs is running out of memory, or is taking a long time to finish</a></h2>

<p> In general, FindBugs requires lots of memory and a relatively
fast CPU.  For large applications, 1024M or more of heap space may be
required.  By default, FindBugs allocates 768M of heap space.
You can increase this using the <code>-maxHeap <i>n</i></code> option,
where <i>n</i> is the number of megabytes of heap space to allocate.


<h2><a name="q4">Q4: What is the "auxiliary classpath"?  Why should I specify it?</a></h2>

<p> Many important facts about a Java class require information about
the classes that it references.&nbsp; For example:
<ul>
<li> What other classes and interfaces the class inherits from
<li> What exceptions can be thrown by methods in external classes
and interfaces
</ul>

<p> The "auxiliary classpath" is a list of Jar files, directories, and
class files containing classes that are <em>used</em> by the code you
want FindBugs to analyze, but should not themselves be analyzed
by FindBugs.

<p> If FindBugs doesn't have complete information about referenced classes,
it will not be able to produce results that are as accurate as possible.&nbsp;
For example, having a complete repository of referenced classes allows
FindBugs to prune control flow information so it can concentrate on
paths through methods that are most likely to be feasible at runtime.&nbsp;
Also, some bug detectors (such as the suspicious reference comparison detector)
rely on being able to perform type inference, which requires complete
type hierarchy information.

<p> For these reasons, we strongly recommend that you completely specify
the auxiliary classpath when you run FindBugs.&nbsp; You can do this
by using the <code>-auxclasspath</code> command line option, or the
"Classpath entries" list in the GUI project editor dialog.

<p> If FindBugs cannot find a class referenced by your application, it
will print out a message when the analysis completes, specifying the
classes that were missing.&nbsp; You should modify the auxiliary classpath
to specify how to find the missing classes, and then run FindBugs again.

<h2><a name="q5">Q5: The Eclipse plugin doesn't load</a></h2>

<p> The symptom of this problem is that Eclipse fails to load
the FindBugs UI plugin with the message:
<blockquote>
Plug-in "edu.umd.cs.findbugs.plugin.eclipse" was disabled due to missing or disabled
prerequisite plug-in "org.eclipse.ui.ide"
</blockquote>

<p> The reason for this problem is that the Eclipse
plugin distributed with FindBugs
does not work with older 3.x versions of Eclipse.
Please use Eclipse version 3.6 (June 2010) or newer.

<h2><a name="q6">Q6: I'm getting a lot of false "OS" and "ODR" warnings</a></h2>

<p> By default, FindBugs assumes that any method invocation can
throw an unchecked runtime exception.&nbsp; As a result,
it may assume that an unchecked exception thrown out of the
method could bypass a call to a <code>close()</code> method
for a stream or database resource.

<p> You can use the <code>-workHard</code> command line argument
or the <code>findbugs.workHard</code> boolean analysis property
to make FindBugs work harder to prune unlikely exception
edges.&nbsp; This generally reduces the number of
false warnings, at the expense of slowing down the
analysis.

<h2><a name="q7">Q7: The Eclipse plugin loads, but doesn't work correctly</a></h2>

<p> Make sure the Java code you trying to analyze is built properly and has no
classpath or compile errors.

<p> Make sure the project and workspace FindBugs settings are valid - in doubt, revert them to defaults.

<p> Make sure the Error log view does not show errors.

<h2><a name="q8">Q8: Where is the Maven plugin for FindBugs?</a></h2>

<p>
The <a href="http://maven.apache.org/">Maven</a> Plugin for FindBugs
may be found <a href="http://mojo.codehaus.org/findbugs-maven-plugin/">here</a>.&nbsp;
Please note that the Maven plugin is not maintained by the FindBugs developers,
so we can't answer questions about it.
</p>

<h2><a name="q9">Q9: Where is the NetBeans plugin for FindBugs?</a></h2>

<p>We recommend <a href="http://kenai.com/projects/sqe/pages/Home">SQE: Software Quality Environment</a>
which bundles FindBugs, PMD and CheckStyle. Use the following
update site:
<a href="http://deadlock.netbeans.org/hudson/job/sqe/lastStableBuild/artifact/build/full-sqe-updatecenter/updates.xml
">http://deadlock.netbeans.org/hudson/job/sqe/lastStableBuild/artifact/build/full-sqe-updatecenter/updates.xml</a>
<p>Pease note that the SQE plugin is not maintained by the FindBugs developers,
so we can't answer questions about it.
</p>

@HTML_FOOTER@

</td>

</table>

</body>

</html>
